package com.lfs.utils;

import java.awt.*;

public class GuiUtil {
    /**
     * 将窗口居中显示
     */
    public static void centerWindow(Window window) {
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        int screenWidth = screenSize.width;
        int screenHeight = screenSize.height;

        int windowWidth = window.getWidth();
        int windowHeight = window.getHeight();

        int x = (screenWidth - windowWidth) / 2;
        int y = (screenHeight - windowHeight) / 2;

        window.setLocation(x, y);
    }
}
